package cn.bugstack.springframework.beans.factory.support;

import cn.bugstack.springframework.beans.BeanException2;
import cn.bugstack.springframework.beans.BeansException;
import cn.bugstack.springframework.beans.factory.config.BeanDefinition2;

public abstract class AbstractAutowireCapableBeanFactory2 extends AbstractBeanFactory2{

    @Override
    protected Object createBean(String beanName, BeanDefinition2 beanDefinition2) throws BeanException2 {
        Object bean = null;
        try {
            bean = beanDefinition2.getBeanClass().newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new BeanException2("Instantiation of bean failed", e);
        }
        addSingleton(beanName,bean);
        return bean;
    }
}
